package thread;

public class threadDemo9 {
    public static long sum=0;
    public static void main(String[] args)throws InterruptedException {
        Thread t1=new Thread(()->{
            for (long i = 0; i <50 ; i++) {
                sum+=i;
            }
        });
        Thread t2=new Thread(()->{
            for (long i = 50; i <=100 ; i++) {
                sum+=i;
            }
        });
        t1.start();
        t2.start();
        long begin=System.currentTimeMillis();
        //Thread.sleep(3000);
        t1.join();
        t2.join();
        long end=System.currentTimeMillis();
        System.out.println("sum="+sum);
        System.out.println("等待时间"+(end-begin)+"ms");
    }
}
